Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
The base32.js npm package provides utilities for encoding and decoding data using the Base32 encoding scheme. This encoding is often used in applications where data integrity and readability are important, such as in QR codes, file names, and URLs.
Base32 Encoding
This feature allows you to encode a string into Base32 format. The code sample demonstrates how to encode the string 'Hello, World!' into its Base32 representation.
const base32 = require('base32.js');
const encoder = new base32.Encoder();
const encoded = encoder.write('Hello, World!').finalize();
console.log(encoded); // Output: JBSWY3DPEBLW64TMMQ======
Base32 Decoding
This feature allows you to decode a Base32 encoded string back to its original form. The code sample demonstrates how to decode the Base32 string 'JBSWY3DPEBLW64TMMQ======' back to 'Hello, World!'.
const base32 = require('base32.js');
const decoder = new base32.Decoder();
const decoded = decoder.write('JBSWY3DPEBLW64TMMQ======').finalize();
console.log(decoded); // Output: Hello, World!
The thirty-two package provides similar functionality for Base32 encoding and decoding. It is straightforward to use but may not offer as many customization options as base32.js.
The base32-encode package focuses solely on encoding data to Base32 format. It is lightweight and easy to use but does not include decoding functionality, making it less versatile than base32.js.
The base32-decode package is designed specifically for decoding Base32 encoded data. Like base32-encode, it is lightweight and easy to use but does not offer encoding capabilities.
Base32 is a base 32 transfer encoding using the twenty-six letters A–Z and six digits 2–7. It is primarily used to encode binary data, but is able to encode binary text like ASCII.
Base32 has number of advantages over Base64:
The resulting character set is all one case (usually represented as uppercase), which can often be beneficial when using a case-insensitive filesystem, spoken language, or human memory.
The result can be used as file name because it can not possibly contain '/' symbol which is usually acts as path separator in Unix-based operating systems.
The alphabet was selected to avoid similar-looking pairs of different symbols, so the strings can be accurately transcribed by hand. (For example, the symbol set omits the symbols for 1, 8 and zero, since they could be confused with the letters 'I', 'B', and 'O'.)
A result without padding can be included in a URL without encoding any characters.
However, Base32 representation takes roughly 20% more space than Base64.
Full documentation at http://mikepb.github.io/base32.js/
$ npm install base32.js
Encoding an array of bytes using Crockford:
var base32 = require("base32.js");
var buf = [1, 2, 3, 4];
var encoder = new base32.Encoder({ type: "crockford", lc: true });
var str = encoder.write(buf).finalize();
// str = "04106173"
var decoder = new base32.Decoder({ type: "crockford" });
var out = decoder.write(str).finalize();
// out = [1, 2, 3, 4]
The default Base32 variant if no type
is provided is "rfc4648"
without
padding.
The browser versions of the library may be found under the dist/
directory.
The browser files are updated on each versioned release, but not for
development. Karma is used to run the mocha tests in the browser.
$ npm install -g karma-cli
$ npm run karma
MIT
FAQs
Base 32 encodings for JavaScript
We found that base32.js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.